/**
 * Copyright (c) 2015-2018, Golly Hu 胡高 (3722711@qq.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.hg.jfsa.manage.controller.system.validator;

import cn.hg.base.jfinal.validator.BaseValidator;
import com.jfinal.core.Controller;

/**
 * @author Golly
 *
 */
public class DictValidator extends BaseValidator {

	/* (non-Javadoc)
	 * @see com.jfinal.validate.Validator#validate(com.jfinal.core.Controller)
	 */
	@Override
	protected void validate(Controller c) {
		this.validateRequired("dict.parentId", "parentMsg", "必须填写上级资源！");
		this.validateRequired("dict.status", "statusMsg", "必须填写状态！");
		this.validateInteger("dict.sortNum", 0, Short.MAX_VALUE, "sortNumMsg", "排序号必须填写0到" + Short.MAX_VALUE + "长度的字符！");
		this.validateString("dict.name", 2, 50, "nameMsg", "名称必须填写2到50长度的字符！！");
		this.validateString("dict.key", 1, 200, "codeMsg", "键必须填写1到200长度的字符！");
		this.validateString("dict.value", 1, 500, "valueMsg", "值必须填写1到500长度的字符！");
	}

	/* (non-Javadoc)
	 * @see com.jfinal.validate.Validator#handleError(com.jfinal.core.Controller)
	 */
	@Override
	protected void handleError(Controller c) {
		c.keepPara();
	}

}
